package com.hnx.admin.mybatisplus;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.hnx.admin.api.service.user.LoginUserAPI;
import lombok.RequiredArgsConstructor;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

/*
项目名称： core
创 建 人: 倔强的头发
创建日期： 2025/6/6   20:21:54 
描   述：
*/
@Component
@RequiredArgsConstructor
public class MyMetaObjectHandler implements MetaObjectHandler {
    private final LoginUserAPI userAPI;
    @Override
    public void insertFill(MetaObject metaObject) {
        this.strictInsertFill(metaObject, "createBy", String.class,userAPI.getUserId());
        this.strictInsertFill(metaObject, "updateBy", String.class, userAPI.getUserId());
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.strictUpdateFill(metaObject, "updateBy", String.class, userAPI.getUserId());
    }
}
